package com.studymaster.init;

import org.logicalcobwebs.proxool.ProxoolDataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

public class ApplicationInitializer implements ApplicationListener<ApplicationEvent> {

	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		if (event instanceof ContextRefreshedEvent)
		{
			ApplicationContext applicationContext = ((ContextRefreshedEvent) event).getApplicationContext();
			ProxoolDataSource proxoolDataSource = (ProxoolDataSource) applicationContext.getBean("dataSource");
			proxoolDataSource.setHouseKeepingSleepTime(120);
			System.out.println(proxoolDataSource.getDriverUrl());
		}
	}

}
